<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        `use strict`
        var arr = []
        for (var i =0; i < 5; i++) {
            arr[i] = function () {
                console.log(i) // 
            }
            console.log(i)

        }
        for (var v of arr) {
            v() //  打印出来的全是5   原因是函数内部变量引用外部全局变量   当全局变量改变时函数内部的变量页跟着改变b
        }
        
    </script>
</body>
</html>